Repository navigation
fix(clickhouse): RowPolicy checks that no other row policy is on the table - #32
Merged
fm4v merged 1 commit intoNov 20, 2026
Conversation
…table The RowPolicy oracle compares `SELECT c FROM t WHERE p` with `SELECT c FROM t` under `CREATE ROW POLICY ... USING (p)`. It assumed that its own policy is the only one on the table, but its cleanup is best effort: the `finally` DROP goes through the expected errors, which include transport errors, `Memory limit` and `TIMEOUT_EXCEEDED`. Row policies also survive `DROP DATABASE`, and every database of a thread reuses the same name, so a leaked permissive policy also applies to the next `t0` of that thread. With one present, the baseline sees `old AND p` and the policy read sees `old OR p`, which is reported as a row policy bypass: The size of the result sets mismatch (0 and 11)! SELECT t0.c0 FROM t0 WHERE ((t0.c0)%(t0.c0)) -> 0 SELECT t0.c0 FROM t0 -> 11 Before the baseline, list the policies on the table in system.row_policies; drop any that exist and skip the check. On a mismatch, log the policies on the table, the table state and a re-read row count of the filtered query to the reproducer, then rethrow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fm4v
self-requested a review
November 20, 2026 19:03
fm4v
approved these changes
Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 2026-11-19 master nightly (
SQLancer (arm_release), reproducer) reported aRowPolicyfinding that reads like a row policy bypass:The same table and policy return 0 rows on master in every setting variant I tried. The CI numbers come out exactly when another permissive policy, e.g.
USING (t0.c0 IS NOT NULL), is already on the table: the baseline then readsold AND pand the policy readold OR p.The oracle assumes its policy is the only one on the table, but nothing guarantees it:
DROP ROW POLICYinfinallyis best effort, and the expected errors include transport errors,Memory limitandTIMEOUT_EXCEEDED;DROP DATABASE, and every database of a thread reuses the same name, so a leaked policy also applies to the nextt0of that thread.The nightly keeps no server log, so I cannot show the leftover policy for that run.
Now the oracle lists the policies on the table in
system.row_policiesbefore the baseline; if there are any, it drops them and skips the check. On a mismatch it also logs the policies on the table, the table state and a re-read row count of the filtered query to the reproducer, so a finding that lists only the oracle's own policy points at ClickHouse.Checked:
mvn verify -DskipTests=true -Djacoco.skip=truepasses.--oracle RowPolicyagainst masterec475edd5e3d(debug build,.claude/clickhouse-config/overrides), before and after on one server:finallydrops skipped, local patch), 4 threads, 5 minA forced mismatch (local patch) writes:
Related: ClickHouse/ClickHouse#128538
🤖 Generated with Claude Code